package com.fwzc.giuseppe;

import java.io.File;

import android.app.Application;
import android.content.Context;
import android.widget.TextView;

import com.nostra13.universalimageloader.cache.disc.impl.UnlimitedDiscCache;
import com.nostra13.universalimageloader.cache.disc.naming.Md5FileNameGenerator;
import com.nostra13.universalimageloader.core.ImageLoader;
import com.nostra13.universalimageloader.core.ImageLoaderConfiguration;
import com.nostra13.universalimageloader.core.assist.QueueProcessingType;
import com.nostra13.universalimageloader.utils.StorageUtils;

public class MyApplication extends Application{
	
	
	private static MyApplication mInstance;
	
	public TextView mTitleTextView;

	/** 上一次的状态 */
	public int mPreviousTabIndex = 1;
	/** 当前状态 */
	public int mCurrentTabIndex = 1;

	public static MyApplication getInstance() {
		return mInstance;
	}
	public static void initImageLoader(Context context) {
		File cacheDir = StorageUtils.getOwnCacheDirectory(context,
				"giuseppe/Cache");
		// This configuration tuning is custom. You can tune every option, you
		// may tune some of them,
		// or you can create default configuration by
		// ImageLoaderConfiguration.createDefault(this);
		// method.
		@SuppressWarnings("deprecation")
		ImageLoaderConfiguration config = new ImageLoaderConfiguration.Builder(
				context)
				.threadPoolSize(3)
				// 线程池内加载的数量
				// .memoryCache(new WeakMemoryCache()) // You can pass your own memory cache implementation/你可以通过自己的内存缓存实现
//				.memoryCache(new UsingFreqLimitedMemoryCache(2 * 1024 * 1024)) // You can pass your own memory cache implementation/你可以通过自己的内存缓存实现  
				.threadPriority(Thread.NORM_PRIORITY - 2)
				.denyCacheImageMultipleSizesInMemory()
				.discCacheFileNameGenerator(new Md5FileNameGenerator())//将保存的时候的URI名称用MD5 加密  
				.tasksProcessingOrder(QueueProcessingType.LIFO)
				.writeDebugLogs() // Not necessary in common
				.diskCacheSize(50 * 1024 * 1024) // 50 MiB
				.discCache(new UnlimitedDiscCache(cacheDir))// 自定义缓存路径
				.tasksProcessingOrder(QueueProcessingType.LIFO)
//				.discCacheFileCount(100) //缓存的文件数量  
				
				// .imageDownloader(new BaseImageDownloader(context, 5 * 1000,
				// 30 * 1000)) // connectTimeout (5 s), readTimeout (30 s)超时时间
				.build();
		// Initialize ImageLoader with configuration.
		ImageLoader.getInstance().init(config);

	}

	public Context context;

	@Override
	public void onCreate() {
		super.onCreate();
		mInstance = this;
		
	}
	

}
